import java.util.regex.Pattern;

import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTML.Attribute;
import javax.swing.text.html.HTML.Tag;


public abstract class IProvider {
	public class SearchDetails{
		public String RegEx = null;
		public int RegExGroupNum = 1;
		HTML.Tag ATagSearch = null;
		HTML.Tag BTagSearch = null;
		
		public String RegExAttribute = null;
		public int RegExAttributeGroupNum = -1;
		HTML.Attribute TTagAtribute = null;
		
		private Pattern _searchpat = null;
		public Pattern get_searchpat() {
			if(this.RegEx == null || this.RegEx.length() == 0)
				return null;
			if(_searchpat == null)
				_searchpat = Pattern.compile(this.RegEx);
			return _searchpat;
		}
		private Pattern _searchpatAt = null;
		public Pattern get_searchpatAt() {
			if(this.RegExAttribute == null || this.RegExAttribute.length() == 0)
				return null;
			if(_searchpatAt == null)
				_searchpatAt = Pattern.compile(this.RegExAttribute);
			return _searchpatAt;
		}
		
		public SearchDetails(String regEx, int regExGroupNum, Tag aTagSearch,
				Tag bTagSearch) {
			super();
			RegEx = regEx;
			RegExGroupNum = regExGroupNum;
			ATagSearch = aTagSearch;
			BTagSearch = bTagSearch;
		}
		
		public SearchDetails(String regEx, int regExGroupNum, Tag aTagSearch,
				Tag bTagSearch, String regExAttribute,
				int regExAttributeGroupNum, Attribute tagAtribute) {
			super();
			RegEx = regEx;
			RegExGroupNum = regExGroupNum;
			ATagSearch = aTagSearch;
			BTagSearch = bTagSearch;
			RegExAttribute = regExAttribute;
			RegExAttributeGroupNum = regExAttributeGroupNum;
			TTagAtribute = tagAtribute;
		}
	}

	public IProvider(BotConfig cfg){		
	}
	
	
	protected abstract String getEnginName();
	protected abstract String getSearchURL(int Year, String useCase, String categ);
	protected abstract String getURL(String extUrl);
	
	protected abstract SearchDetails getPositionCountSearch();
	protected int finalPositionCountTest(HTMLDocument htmlDoc) {
		return 0;
	}
	
	protected SearchDetails getPositionDetailSearch(){
		return null;
	}
	protected SearchDetails getNextSearch(){
		return null;
	}
	protected SearchDetails getNextDetail(){
		return null;
	}
	
	protected abstract int getKeyWordCount();
	protected abstract String getKeyWordName(int idx);
	protected abstract SearchDetails getKeySearchDetails(int idx);	
}
